steps[n_] := Table[(-1)^Random[Integer], {n}]

steps[10]

FoldList[Plus, 0, %]

Walk1D[n_] :=  FoldList[Plus, 0, Table[(-1)^Random[Integer], {n}]]

Walk1D[10]

Walk2D[n_] := FoldList[Plus, {0, 0}, 
{{0,1},{1,0},{0,-1},{-1,0}}[[Table[Random[Integer, {1, 4}], {n}]]]]

Walk2D[20]

Apply[Plus, {xf, yf}^2]

SquareDistance[walk_List] := Apply[Plus, Last[walk]^2]

Walk2D[10]

SquareDistance[ Walk2D[10] ]

SquareDistance[ Walk2D[10] ]

\(AverageDistance[n_Integer, \ m_Integer]\  := \ 
	
      Module[{w2D, w, t}, 
	
        w2D[s_] := 
          FoldList[
            Plus, \ {0, 
              0}, \ 
\ \ \ \ \ \ \ \ \ \ \ {{0, 1}, {1, 
                  0}, {0, \(-1\)}, {\(-1\), 
                  0}}
			\ \ \ \ \ \ \ [\([Table[
                  Random[Integer, {1, 4}], {s}]]\)]]; 
		t := 
          Table[Last[w2D[n]], \ {m}]; 
	{Sum[
              Apply[Plus, t[\([w]\)]^2], \ {w, 1, m}]/m, 	\ 
	
          Sum[Sqrt[Plus\  @@ \ \ t[\([w]\)]^2], \ {w, 1, m}]/m}]\)

Table[AverageDistance[10,30]//N,{10}]

ShowWalk2D[coords_, opts___]:=
	Show[Graphics[Line[coords],
		opts, AspectRatio -> Automatic]]

units[xmin_, xmax_] := Range[Floor[xmin], Floor[xmax], 1]

w = Walk2D[50]

xmin = Min[Map[#[[1]] &, w]]

xmax = Max[Map[#[[1]] &, w]]

ymin = Min[Map[#[[2]] &, w]]

ymax = Max[Map[#[[2]] &, w]]

units[xmin, xmax]

units[ymin, ymax]

ShowWalk2D[w, Ticks->{units[xmin,xmax],units[ymin,ymax]},
Axes->True, AspectRatio->1] ;

ShowWalk2D[ Walk2D[500],
	DefaultColor -> Hue[.5],
	Background -> GrayLevel[0.5],Axes->True, AspectRatio->1 ] ;

Walk2D[n_] := FoldList[Plus, {0, 0}, 
{{0,1},{1,0},{0,-1},{-1,0}}[[Table[Random[Integer, {1, 4}], {n}]]]]

ShowWalk2D[coords_, opts___]:=
	Show[Graphics[Line[coords],
		opts, AspectRatio -> Automatic]]

tickunits[a_, b_] := Range[Floor[a], Ceiling[b], 1]

w = Walk2D[50]

xmin = Min[Map[#[[1]] &, w]]; 
    xmax = Max[Map[#[[1]] &, w]];
ymin = Min[Map[#[[2]] &, w]]; 
    ymax = Max[Map[#[[2]] &, w]];
{tickunits[xmin, xmax], tickunits[ymin, ymax]}

ShowWalk2D[w,Axes->True, AspectRatio->1]

ShowWalk2D[w,Axes->True, AspectRatio->1,Ticks->{tickunits[xmin,xmax],tickunits[ymin,ymax]}]